home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine CD 1995
/
Archive Magazine CD 1995.iso
/
discs
/
pipeline
/
8_12
/
Lottery
/
c_LotMath
< prev
next >
Wrap
Text File
|
1995-06-27
|
2KB
|
67 lines
%OP%VS4.13 (28-Apr-92), The Bindon Family, R4001 0009 7093 7995
%OP%TNN
%OP%DP0
%OP%PL66
%OP%HM0
%OP%FM0
%OP%BM0
%OP%PT1
%OP%PDDotMatrix
%OP%WC2,1522,78,1132,0,0,0,0
%CO:A,80,0%%V%%L%function("NumCount","a:array","c:array","d:array")
\ "c" is a 2 x 49 array to count instances of 1...49
\ Set the first column of "c" to 1...49
\ Set the second column of "c" to zeros
%V%%L%for("i",1,49)
%V%%L%set_value(index(@c,1,i),i)
%V%%L%set_value(index(@c,2,i),0)
%V%%L%next
\ Count the numbers 1...49 in array "a" skipping blanks
%V%%L%set_name("n",0)
%V%%L%for("i",1,cols(@a))
%V%%L%for("j",1,rows(@a))
%V%%L%if(index(@a,i,j)=" ",goto(A16),)
%V%%L%set_name("v",index(@a,i,j))
%V%%L%set_value(index(@c,2,v),index(@c,2,v)+1)
%V%%L%next
%V%%L%next
\ Insertion sort of counted balls in descending order
%V%%L%for("i",1,48)
%V%%L%set_name("k",i)
%V%%L%for("j",i+1,49)
%V%%L%if(index(@c,2,j)>index(@c,2,k),set_name("k",j),)
%V%%L%next
\ Note that INDEX(,,) always returns a CELL REFERENCE
\ and contents may change DEREF( takes value
%V%%L%if(i=k,goto(A35),)
%V%%L%set_name("t",deref(index(@c,1,k)))
%V%%L%set_name("u",deref(index(@c,2,k)))
%V%%L%for("j",k,i+1,-1)
%V%%L%set_value(index(@c,1,j),index(@c,1,j-1))
%V%%L%set_value(index(@c,2,j),index(@c,2,j-1))
%V%%L%next
%V%%L%set_value(index(@c,1,i),t)
%V%%L%set_value(index(@c,2,i),u)
%V%%L%next
\
\ find distribtion of ball success in 2 x 21 arraray "d"
\ index function does not allow index 0
%V%%L%for("nb",1,21)
%V%%L%set_value(index(@d,1,nb),0)
%V%%L%next
\ Note that @c and @d arrays must be large enough for "j" and "nb" ranges
%V%%L%for("j",1,49)
%V%%L%for("nb",0,20)
%V%%L%if(index(@c,2,j)=nb,set_value(index(@d,1,nb+1),index(@d,1,nb+1)+1),)
%V%%L%next
%V%%L%next
%V%%L%result("done")
\
%V%%L%function("fac","i:number")
%V%%L%if(@i=0,result(1),)
%V%%L%set_name("n",1)
%V%%L%for("j",@i,1,-1)
%V%%L%set_name("n",n*j)
%V%%L%next
%V%%L%result(n)